﻿//***************************************************************************//
//                                                                           //
//Author:       Kris Henry                                                   //
//Class Name:   Credits.cs                                                   //
//Pupose:       Handle the drawing credits screen                            //
//              ingame attributes                                            //
//Date :        December 2012                                                //
//                                                                           //
//***************************************************************************//


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Indie_Game_Contest
{
    class Credits : IGameState
    {
        private int creditFont;
        private Vector2 position = new Vector2(310, WorldData.WindowHeight+ 50);
        private static Credits instance;
        private int count;
        private int stage;
        bool done;
        private int bgID;

        private Credits()
        {

        }
        public static Credits Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new Credits();
                }
                return instance;
            }
        }
        public int CreditFont
        {
            get { return creditFont; }
            set { creditFont = value; }
        }
        override public void Update(float dt)
        {
            if (count % 1 == 0)
            {
                position = new Vector2(310, position.Y - 2);

                if (stage == 3 && position.Y < -110)
                    Game1.Instance.RemoveState();
            }
            count++;

            if (done)
            {
                done = false;
                position = new Vector2(310, WorldData.WindowHeight + 50);
                stage++;
            }
        }
        override public bool Input()
        {
            if (CInput.Instance.KeyPressed(Keys.Escape) || CInput.Instance.GamePadButtonPressed(Buttons.B) ||
                CInput.Instance.KeyPressed(Keys.Enter)  || CInput.Instance.GamePadButtonPressed(Buttons.A) ||
                CInput.Instance.KeyPressed(Keys.Space)  || CInput.Instance.GamePadButtonPressed(Buttons.Start) ||
                CInput.Instance.GamePadButtonPressed(Buttons.Back))
            {
                Game1.Instance.RemoveState();
            }

            return true;
        }
        override public void Render()
        {
            WorldData.spriteBatch.Draw(TextureManager.Instance.GetTexture(bgID),new Rectangle(0,0,WorldData.WindowWidth,WorldData.WindowHeight),
                    Color.FromNonPremultiplied(255,255,255,200));
            switch(stage)
            {
                case 0:
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(CreditFont), "      Credits",position, Color.White);
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(CreditFont), "____________________", new Vector2(position.X - 50, position.Y + 15), Color.White);

                    if (position.Y +15< -10)
                        done = true;
                    break;
                case 1:
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(CreditFont), "Developers", position, Color.White);
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(CreditFont), "Team .exeCutives",new Vector2( position.X-30,position.Y+50), Color.White);
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(CreditFont), "_________________________",new Vector2( position.X-50,position.Y+75), Color.White);
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(CreditFont), "Tony Ashby",new Vector2( position.X-10,position.Y+150), Color.White);
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(CreditFont), "Ja'Michael Garcia",new Vector2( position.X-10,position.Y+200), Color.White);
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(CreditFont), "Kristoffer Henry",new Vector2( position.X-10,position.Y+250), Color.White);
                    if (position.Y + 250 < -10)
                        done = true;
                    break;
                case 2:
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(CreditFont), "Special Thanks", position, Color.White);
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(CreditFont), "____________________", new Vector2(position.X - 50, position.Y + 15), Color.White);
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(CreditFont), "OpenGameArt.org", new Vector2(position.X - 50, position.Y + 50), Color.White);
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(CreditFont), "FlashKit.com", new Vector2(position.X - 50, position.Y + 100), Color.White);
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(creditFont), "www.Kenney.nl", new Vector2(position.X - 50, position.Y + 150), Color.White);
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(creditFont), "Tom Peter", new Vector2(position.X - 50, position.Y + 200), Color.White);
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(creditFont), "http://soundcloud.com/", new Vector2(position.X - 50, position.Y + 250), Color.White);
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(creditFont), "tom-peter", new Vector2(position.X - 50, position.Y + 300), Color.White);
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(creditFont), "Full Sail University", new Vector2(position.X - 50, position.Y + 350), Color.White);
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(creditFont), "Red Bull", new Vector2(position.X - 50, position.Y + 400), Color.White);
                    if (position.Y + 100 < -10)
                        done = true;
                    break;
                case 3:
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(CreditFont), "This game was developed as  ", new Vector2(position.X-130,position.Y), Color.White);
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(CreditFont), "part of Indie Speed Run 2012", new Vector2(position.X - 90, position.Y + 25), Color.White);
                    WorldData.spriteBatch.DrawString(TextureManager.Instance.GetSpriteFont(CreditFont), "(www.indiespeedrun.com)", new Vector2(position.X-90,position.Y+50), Color.White);

                    
                    break;
            }
        }
        override public void Enter()
        {

        }
        override public void Exit()
        {

        }

        public int BgID
        {
            get { return bgID; }
            set { bgID = value; }
        }
    }
}
